﻿namespace FrameWork.Request
{
    public class RequestResponseModel<T>
    {
        /// <summary>
        /// 状态码
        /// </summary>
        public int Status { get; set; }

        /// <summary>
        /// 信息
        /// </summary>
        public string Message { get; set; }

        /// <summary>
        /// 数据
        /// </summary>
        public T Data { get; set; }
    }


    public class RequestResponse
    {
        /**
         * 创建返回
         */
        public static RequestResponseModel<T> CreateResponse<T>(int Status, string Message, T? Data)
        {
            return new RequestResponseModel<T>
            {
                Status = Status,
                Message = Message,
                Data = Data
            };
        }

        /**
         * 400 - 传入参数错误
         */
        public static RequestResponseModel<T> BadRequest<T>(string Message, T? Data)
        {
            return CreateResponse(400, Message, Data);
        }

        /**
         * 500 - 服务器错误
         */
        public static RequestResponseModel<string> ServerError(string Message)
        {
            return CreateResponse(500, "未知错误，请联系管理员！", "");
        }

        /**
         * 200 - 成功调用
         */
        public static RequestResponseModel<T> OK<T>(string Message, T Data)
        {
            return CreateResponse(200, Message, Data);
        }
    }
}
